package com.zhengbing.tj.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhengbing.tj.entity.RolePermission;
import com.zhengbing.tj.mapper.RolePermissionMapper;
import com.zhengbing.tj.service.RolePermissionService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 角色权限关联服务实现类
 * 处理角色权限关联实体的具体业务逻辑
 *
 * @author zhengbing
 * @date 2024-08-22
 */
@Service
public class RolePermissionServiceImpl extends ServiceImpl<RolePermissionMapper, RolePermission> implements RolePermissionService {
    
    @Override
    public boolean removeByRoleId(Long roleId) {
        QueryWrapper<RolePermission> wrapper = new QueryWrapper<>();
        wrapper.eq("role_id", roleId);
        return remove(wrapper);
    }
    
    @Override
    public boolean removeByPermissionId(Long permissionId) {
        QueryWrapper<RolePermission> wrapper = new QueryWrapper<>();
        wrapper.eq("permission_id", permissionId);
        return remove(wrapper);
    }
    
    @Override
    public List<Long> selectPermissionIdsByRoleId(Long roleId) {
        return getBaseMapper().selectPermissionIdsByRoleId(roleId);
    }
    
    @Override
    public List<Long> selectRoleIdsByPermissionId(Long permissionId) {
        return getBaseMapper().selectRoleIdsByPermissionId(permissionId);
    }
}